package cn.com.fuhuitong.main.home.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import cn.com.fuhuitong.app.BaseApplication
import cn.com.fuhuitong.base.BaseViewModel
import cn.com.fuhuitong.base.SafeMutableLiveData
import cn.com.fuhuitong.http.BaseResponse
import cn.com.fuhuitong.http.HttpResponse
import cn.com.fuhuitong.http.ViewModelSubscribeListener
import cn.com.fuhuitong.main.home.entity.*
import cn.com.fuhuitong.main.home.mode.HomeManager
import io.reactivex.disposables.Disposable

class BulletinViewModel(application: Application) : BaseViewModel(application) {

    private val homeManager: HomeManager = HomeManager()

    val bulletinListLiveData = MutableLiveData<HttpResponse<BulletinListResponse>>()


    private var page: Int = 1
    private var limit: Int = 20

    /**
     * 获取公益慈善列表
     */
    fun expressNewsList() {
        val listener =
            object : ViewModelSubscribeListener<BulletinListResponse>(bulletinListLiveData) {}
        val expressNewsListDisposable: Disposable = homeManager.expressNewsList(
            page.toString(), limit.toString(), listener
        )
        dispose.add(expressNewsListDisposable)
    }
}